//
//  VisualDetailViewController.m
//  礼物
//
//  Created by dllo on 15/11/13.
//  Copyright © 2015年 liangsicheng. All rights reserved.
//

#import "VisualDetailViewController.h"

@interface VisualDetailViewController ()

@end

@implementation VisualDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //导航栏标题
      self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"iconfont-fanhui.png"] style:UIBarButtonItemStyleDone target:self action:@selector(leftBarButtonItemAction:)];
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 44)];
    titleLabel.text = self.model.title;
    titleLabel.textColor = [UIColor whiteColor];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:17];
    self.navigationItem.titleView = titleLabel;
    
    //重写初始化将数据传入
    self.videoDetailV = [[VideoDetailView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT - 64) VideoModel:self.model];
    self.videoDetailV.myDelegate = self;//成为代理人
    [self.view addSubview:self.videoDetailV];
    
    
    //    //时间戳转化时间(13位时间戳)
    //    NSString * timeStampString = [NSString stringWithFormat:@"%ld",self.videoModel.date];
    //    NSTimeInterval _interval=[timeStampString doubleValue] / 1000.0;
    //    NSDate *date = [NSDate dateWithTimeIntervalSince1970:_interval];
    //    NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
    //    [formatter setDateFormat:@"yyyyMMdd"];
    //    NSString *currentDate = [formatter stringFromDate:date];
    //    self.currentDate = [currentDate integerValue];//字符转NSInteger
    //    //NSLog(@"%ld", self.currentDate);
    
    
    
}
-(void)leftBarButtonItemAction:(UIBarButtonItem *)barButtonItem
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)pushToPlayerViewController
{
    PlayerViewController *playerVC = [[PlayerViewController alloc] init];
    playerVC.videoModel = self.model;
    
    if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
        SEL selector = NSSelectorFromString(@"setOrientation:");
        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
        [invocation setSelector:selector];
        [invocation setTarget:[UIDevice currentDevice]];
        int val = UIInterfaceOrientationLandscapeRight;
        [invocation setArgument:&val atIndex:2];
        [invocation invoke];
        
        
    }

    //模态
    [self presentViewController:playerVC animated:YES completion:^{
    }];
    //[self.navigationController pushViewController:playerVC animated:YES];
}

- (void)leftBarAction
{
    [self.navigationController popViewControllerAnimated:YES];
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
